const { Menu,BrowserWindow } = require("electron");
var template = [
  {
    label: "首页",
    submenu: [
      {
        label: "菜单1",
        click: () => {
          var win = new BrowserWindow({
            width: 500,
            height: 500,
            webPreferences: {
              nodeIntegration: true
            }
          })
          win.loadFile('yellow.html');
          win.on('closed',()=>{
              win = null
          })
        },
      },
      {
        label: "菜单2",
        click: () => {
            // mainWindow.minimize()
            console.log('菜单2')
        },
      },
    ],
  },
  {
    label: "其它",
    submenu: [
      {
        label: "其它1",
        click: () => {
            // mainWindow.maximize()
            console.log('qt 1')
            try {
                mainWindow.maximize()
            } catch (error) {
                console.log(error)
            }
        },
      },
      {
        label: "其它2",
      },
    ],
  },
];
var m = Menu.buildFromTemplate(template)

Menu.setApplicationMenu(m)

